package com.ruoyi.web.controller.basedata;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basedata.domain.BillPaymentRecord;
import com.ruoyi.basedata.service.IBillPaymentRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 缴费记录Controller
 * 
 * @author gdqt
 * @date 2025-04-23
 */
@RestController
@RequestMapping("/basedata/paymentrecord")
public class BillPaymentRecordController extends BaseController
{
    @Autowired
    private IBillPaymentRecordService billPaymentRecordService;

    /**
     * 查询缴费记录列表
     */
    @PreAuthorize("@ss.hasPermi('basedata:paymentrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(BillPaymentRecord billPaymentRecord)
    {
        startPage();
        List<BillPaymentRecord> list = billPaymentRecordService.selectBillPaymentRecordList(billPaymentRecord);
        return getDataTable(list);
    }

    /**
     * 导出缴费记录列表
     */
    @PreAuthorize("@ss.hasPermi('basedata:paymentrecord:export')")
    @Log(title = "缴费记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BillPaymentRecord billPaymentRecord)
    {
        List<BillPaymentRecord> list = billPaymentRecordService.selectBillPaymentRecordList(billPaymentRecord);
        ExcelUtil<BillPaymentRecord> util = new ExcelUtil<BillPaymentRecord>(BillPaymentRecord.class);
        util.exportExcel(response, list, "缴费记录数据");
    }

    /**
     * 获取缴费记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('basedata:paymentrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(billPaymentRecordService.selectBillPaymentRecordById(id));
    }

    /**
     * 新增缴费记录
     */
    @PreAuthorize("@ss.hasPermi('basedata:paymentrecord:add')")
    @Log(title = "缴费记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BillPaymentRecord billPaymentRecord)
    {
        return toAjax(billPaymentRecordService.insertBillPaymentRecord(billPaymentRecord));
    }

    /**
     * 修改缴费记录
     */
    @PreAuthorize("@ss.hasPermi('basedata:paymentrecord:edit')")
    @Log(title = "缴费记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BillPaymentRecord billPaymentRecord)
    {
        return toAjax(billPaymentRecordService.updateBillPaymentRecord(billPaymentRecord));
    }

    /**
     * 删除缴费记录
     */
    @PreAuthorize("@ss.hasPermi('basedata:paymentrecord:remove')")
    @Log(title = "缴费记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(billPaymentRecordService.deleteBillPaymentRecordByIds(ids));
    }
}
